/**
 *`	2.
**/

#include <stdio.h>

// 迭代法
int gcd(int m, int n)
{
	int temp;
	
	if(m <= 0 || n <= 0)
		return 0;

	do 
	{
		temp = m % n;
		m = n;
		n = temp;
	}while(temp);

	return m;
}

// 递归法
int gcd_rec(int m, int n)
{
	int r;
	if(m <= 0 || n <= 0)
		return 0;

	r = m % n;
	
	if(r == 0)
		return n;

	return gcd_rec(n, r);
}

int main()
{
	int m, n;

	scanf("%d %d", &m, &n);
	printf("%d\n", gcd(m, n));
	printf("rec = %d\n", gcd_rec(m, n));
	return 0;
}
